#ifndef __VAR_H__
#define __VAR_H__
#ifdef __cplusplus
extern "C" {
#endif

  
#define JSON_BUFFER_SIZE 512
#define UPDATE_SHOW_DLY       ((Int32U)(0.5 * 2))
  struct timer periodic_timer, arp_timer;
        uip_ipaddr_t ipaddr;
#pragma location = "EMAC_DMA_RAM"
char linebuf[120];			/* Console input buffer */
static unsigned int  offset = 0;

#pragma location = "EMAC_DMA_RAM"
static char SD_BUF[JSON_BUFFER_SIZE]="";
#pragma location = "EMAC_DMA_RAM"
char BUFFER_SD[512];//;[50176];//[10240];
//BYTE BUFFER_SD[10240];//;[50176];//[10240];
#pragma location = "EMAC_DMA_RAM"
char BUFFER_SD_temp[JSON_BUFFER_SIZE]="";
#pragma location = "EMAC_DMA_RAM"
char BUFFER_SD_temp1[512]="";
#pragma location = "EMAC_DMA_RAM"
char BUFFER_SD_temp2[512]="";




int ETH_GO=0;
int GSM_READYF=0;
static int SEND=0;
static int STATUS_CSQ=0;
int TIMER_CSQ=0;
#pragma location = "EMAC_DMA_RAM"
int INIT_SD_TEMP=0;
char SD_temp;
char SD_STR [2] = ""; 
datetime_t now; 
unsigned int n = 0;
int SDRES;
static int ARCHIV_DF=0;

#pragma location = "EMAC_DMA_RAM"
int SD_PACKET_A=0;
#pragma location = "EMAC_DMA_RAM"
int SD_PACKET_SEARCH=0; 
#pragma location = "EMAC_DMA_RAM"
int SD_PACKET_E=0;

  
int SDR_PACKET=0;          
///     static const int   SD_STRL = 7;        
char dir_path;
/* Directory object */
long p1=0, p2, p3;
long pn1=1;
long pn2=2;
char *ptr, *ptr2;
int diX_ethernet=0;
int diXR=0;
int diXR1=0;
int SD_J=0;
int SD_H=0;

#pragma location = "EMAC_DMA_RAM"
int  Search_last_arh=0;
#pragma location = "EMAC_DMA_RAM"
int SD_Z=0;
#pragma location = "EMAC_DMA_RAM"
int SD_F=0;
#pragma location = "EMAC_DMA_RAM"
int TC_UP=0;
//............................ETHERNET
//HOST
          int NET1_HOST     =192;
          int NET2_HOST     =168;
          int NET3_HOST     =3;
          int NET4_HOST     =179/*179*/;
          int NET_PORT_OPC =5004/*5004*/;
#define OPCX_PORT 2	            
//CLIENT          
          int NET1_CL       =192;
          int NET2_CL       =168;
          int NET3_CL       =3;
          int NET4_CL       =251;
          int NET_PORT_DEV  =80;
#define CONFIGX_PORT 1	       
//GETEWAY
          int NET1_GW       =192;
          int NET2_GW       =168;
          int NET3_GW       =3;
          int NET4_GW       =1;    
//MASK
          int NET1_MASK     =255;
          int NET2_MASK     =255;
          int NET3_MASK     =255;
          int NET4_MASK     =0;             
                 
//............................ETHERNET

volatile unsigned long ul;
unsigned int  UPXFF = 500;
unsigned int  UPX1 = 1000;
unsigned int  SDHC = 1;
unsigned int  SD_SLEN = 0;
#pragma location = "EMAC_DMA_RAM"
char buffer[10]="";
volatile DWORD Timer;		/* 1kHz increment timer */
unsigned int transmit_ctr = 0;
bool read_data_storage();
bool runner_read_storage(bool reset);
volatile Boolean TickFlag = FALSE;
Int32U Dly = UPDATE_SHOW_DLY;

#pragma location = "EMAC_DMA_RAM"
  int last_var=0;
#pragma location = "EMAC_DMA_RAM"
    int last_var1=0;
    
DiskStatusCode_t StatusHold = (DiskStatusCode_t) -1;
Int32U Size,Tmp;

WORD rtcYear = 2012;
BYTE rtcMon = 3, rtcMday = 14, rtcHour = 11, rtcMin = 55, rtcSec = 0;
/* Priorities for the demo application tasks. */
#pragma location = "EMAC_DMA_RAM"
char FDD[64]="";

#define mainCOM_TEST_BAUD_RATE		( ( unsigned long ) 9600 )

#define mainLED_TASK_PRIORITY		( tskIDLE_PRIORITY + 3 )
#define mainQUEUE_POLL_PRIORITY		( tskIDLE_PRIORITY + 2 )
#define mainCHECK_TASK_PRIORITY		( tskIDLE_PRIORITY + 4 )
#define mainSEM_TEST_PRIORITY		( tskIDLE_PRIORITY + 1 )
#define mainBLOCK_Q_PRIORITY		( tskIDLE_PRIORITY + 2 )
#define mainCOM_TEST_PRIORITY		( tskIDLE_PRIORITY + 2 )

/* Constants required by the 'Check' task. */
//#define mainNO_ERROR_FLASH_PERIOD	( ( portTickType ) 3000 / portTICK_RATE_MS  )
//#define mainERROR_FLASH_PERIOD		( ( portTickType ) 500 / portTICK_RATE_MS  )
#define mainCHECK_TASK_LED			( 7 )

/* Constants for the ComTest tasks. */

#define mainCOM_TEST_LED			( 4 )
#define mainTX_ENABLE				( ( unsigned long ) 0x0001 )
#define mainRX_ENABLE				( ( unsigned long ) 0x0004 )

/* Constants to setup the PLL. */
#define mainPLL_MUL_5				( ( unsigned char ) 0x0004 )
#define mainPLL_DIV_1				( ( unsigned char ) 0x0000 )
#define mainPLL_ENABLE				( ( unsigned char ) 0x0001 )
#define mainPLL_CONNECT				( ( unsigned char ) 0x0003 )
#define mainPLL_FEED_BYTE1			( ( unsigned char ) 0xaa )
#define mainPLL_FEED_BYTE2			( ( unsigned char ) 0x55 )
#define mainPLL_LOCK				( ( unsigned long ) 0x0400 )

/* Constants to setup the MAM. */
#define mainMAM_TIM_3				( ( unsigned char ) 0x03 )
#define mainMAM_MODE_FULL			( ( unsigned char ) 0x02 )

/* Constants to setup the peripheral bus. */
#define mainBUS_CLK_FULL			( ( unsigned char ) 0x01 )

/* And finally, constant to setup the port for the LED's. */
#define mainLED_TO_OUTPUT			( ( unsigned long ) 0xff0000 )
#pragma location = "EMAC_DMA_RAM"
extern volatile BYTE I2CBuffer[28];

#pragma location = "EMAC_DMA_RAM"
extern volatile BYTE UARTBuffer[28];
      //  FATFS fatfs[1];		/* File system object for each logical drive */      
        
int ETHERNET_time=0;

#pragma location = "EMAC_DMA_RAM"
char BUFF_ETH[512];
#ifdef __cplusplus
}
#endif
#endif /* __UIP_H__ */